package com.itrip.itrptrade;

import com.alipay.api.AlipayApiException;
import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import com.alipay.api.request.AlipayTradeRefundRequest;
import com.alipay.api.response.AlipayTradeRefundResponse;

/**
 * @author: 罗坤
 * @description: 1
 * @date: 2020/3/13 18:14
 */
public class test {
    public static void main(String[] args) throws AlipayApiException {
        AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do","2016101900723109","MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCuKHOwFE3G1OjaW9pGMBch1Oug7nYTCDmqByes2H3qnJX6ZO1byqgYV+ID4sGwhxDAlO41MFk+nAr7cTodopVTZYwXlmRgpvgjX9+iezYJXmBAD6G4Ouf6kuFB43lKh9Kp73xuKcpcqc4EhiOt2JkeZI2D7tHeThsoeBovCPdhOgjSnU1cR81eCM58e8AaaCow1yu4H6SMyemEXFMmGWt6S6jYnDM9a+NVr6oUcgV64dHrUIfEE/V0KSLfbbV4LNRe3pUOpkP6WS58Dewk7H3tiukJiHIHPckxsQ3QTYKsAcIdOXTbawVsIxEzFwcV9urs1N+u5+baYyUiaBRH1pkRAgMBAAECggEAb9eMi8xOMl0yeGA6aY6inFhnRX8+FnTWy0kzAn45RrxuWFIOWD9p+dAeVk5+AoaKjJJX85JsDZgaOWV6Y+OwL9FryQ4MwkEX42fDb03e4t9XwmwHeA9kQHeo7y5NCz70W6tvZjOyQBXQNvmJ2i/aDTmX490vq6rPKAsRDZmdfDK+DmXWqHIqVXth0k2yjtgB9BipOiIXZLAdx5l6X+tgBB2I7rUKh5HH/BthOjKbMuWiVYAMVS+KcSr/D4dCYiThoai4lEKPtlr2iIei/o2/bcPXsapQ42VuXEsHk6tDm1tIYrGEtCEwVA7vm5FnFJlQRbgNz6OtVvTr+ceBWcYJ7QKBgQDyJF4vtek2ZXyW4YcehMjb2rDLo8JaD3tnhCQtxgSn/mI24pNhywGRi34hN4Ms2fwr4Yp2Scc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4e1lwsweoL9/FH8ZjEzSlYNXDlt8xli2DdRVDjSRiy2ZpqyOivFoC1o7tQP4O7SQc2ffjRKWvnjDD4p6aAnqcCp10AYHlkKsE6NzA/C2tT4n/ewnpulfqdjM10O/s9QIDAQAB");
        AlipayTradeRefundRequest request = new AlipayTradeRefundRequest();
        request.setBizContent("{" +
                "    \"out_trade_no\":\"D10000012017063017394845d095\"," +
                "    \"trade_no\":\"2020031322001409440501146478\"," +
                "    \"refund_amount\":550," +
                "    \"refund_reason\":\"正常退款\"," +
                "    \"out_request_no\":\"HZ01RF001\"," +
                "    \"operator_id\":\"OP001\"," +
                "    \"store_id\":\"NJ_S_001\"," +
                "    \"terminal_id\":\"NJ_T_001\"" +
                "  }");
        AlipayTradeRefundResponse response = alipayClient.execute(request);
        if(response.isSuccess()){
            System.out.println("调用成功");
        } else {
            System.out.println("调用失败");
        }
    }
}
